#!/usr/bin/env bash

requirements_termux_lib_installed()
{
  pkg-query -s "$1" > /dev/null 2>&1 || return $?
}

requirements_termux_libs_install()
{
  pkg install "$@" || return $?
}

requirements_termux_libs_remove()
{
  pkg --yes remove "$@" || return $?
}

requirements_termux_define_base()
{
  requirements_check "$@" \
    autoconf automake bison ca-certificates curl libc6-dev libffi-dev libgdbm-dev libncurses5-dev \
    libsqlite3-dev libtool libyaml-dev make openssl patch pkg-config sqlite3 zlib1g zlib1g-dev

  requirements_${_system_name_lowercase}_define_libgmp
  requirements_${_system_name_lowercase}_define_libreadline
}

requirements_termux_define()
{
  case "$1" in
    (rvm)
      requirements_check bash curl patch bzip2 ca-certificates gawk
      ;;

    (*)
      requirements_check clang coreutils curl gawk git gnupg gpgv \
                         libc++ libclang libclang-dev libllvm libxml2 make ncurses ncurses-ui-libs \
                         openssl openssl-dev openssl-tool readline sqlite tar zlib zlib-dev
      ;;
  esac
}
